/**
 * 
 */
package com.ekingstar.framework.action;

import org.apache.struts2.config.Action;

import com.opensymphony.xwork2.ActionSupport;
import com.ekingstar.framework.app.ApplicationParameter;
import com.ekingstar.framework.domain.Role;
import com.ekingstar.framework.service.IRoleService;
import com.ekingstar.framework.util.Page;

/**
 * 
 *
 */
@Action(name="list",namespace="/role")
public class ListRoleAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private IRoleService roleService;
	
	private Role role;
	private Page page;
	public Page getPage() {
		return page;
	}
	public void setPage(Page page) {
		this.page = page;
	}
	private int pageNo = 1;
	private int pageSize = ApplicationParameter.INSTANCE.getPageSize();
	public int getPageNo() {
		return pageNo;
	}
	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	
	
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}
	public void setRoleService(IRoleService roleService) {
		this.roleService = roleService;
	}
	public String deleteRole(){
		if (role == null || role.getId() == null || role.getId().trim().equals("")) return "list";
		roleService.deleteRole(role.getId());
		page = roleService.queryRoles(role, pageNo, pageSize);	
		return "list";
	}
	public String execute(){
		page = roleService.queryRoles(role, pageNo, pageSize);
		return "list";
	}
}
